//
//  UserExchangeDiamondCell.m
//  CheekiOS
//
//  Created by mac on 2017/6/26.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "UserExchangeDiamondCell.h"

@interface UserExchangeDiamondCell()

@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *numberLab;

@property (nonatomic, strong) UIButton *numBtn;
@property (nonatomic, strong) UILabel *linLab;
@property (nonatomic, strong) NSIndexPath *indexPath;

@end

@implementation UserExchangeDiamondCell

+(instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *UserExchangeDiamondCellIdent = @"UserExchangeDiamondCellIdent";
    
    UserExchangeDiamondCell *cell = [tableView dequeueReusableCellWithIdentifier:UserExchangeDiamondCellIdent];

    if (!cell) {
        cell = [[UserExchangeDiamondCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UserExchangeDiamondCellIdent];
    }
    cell.indexPath = indexPath;
    return cell;

}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.imgView = [[UIImageView alloc] init];
        [self addSubview:self.imgView];
        
        self.numberLab = [[UILabel alloc] init];
        self.numberLab.font = FontP(16);
        self.numberLab.textColor = [UIColor blackColor];
        [self addSubview:self.numberLab];
        
     
        
        self.numBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.numBtn.layer setMasksToBounds:YES];
        [self.numBtn.layer setBorderWidth:1.0]; //边框宽度
        self.numBtn.layer.borderColor=Colorbackground.CGColor;
        self.numBtn.titleLabel.font = FontP(16);
        
        [self.numBtn setTitleColor:Colorbackground forState:UIControlStateNormal];
        [self addSubview:self.numBtn];
        
        self.linLab = [[UILabel alloc] init];
        self.linLab.backgroundColor = RGB(243, 243, 243);
        [self addSubview:self.linLab];

        
        
        
    }
    return self;
}

-(void)setNumberArray:(NSArray *)numberArray {
    
    _numberArray = numberArray;
    
    
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(50);
        make.height.with.mas_equalTo(15);
        make.top.equalTo(self.mas_centerY).offset(-7.5);
    }];
    
    
    [self.numberLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imgView.mas_right).offset(7);
        make.height.with.mas_equalTo(15);
        make.top.equalTo(self.mas_centerY).offset(-7.5);
    }];
    
    

    
    [self.linLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(50);
        make.right.equalTo(self).offset(-50);
        make.height.mas_equalTo(1);
        make.bottom.equalTo(self).offset(1);
    }];
    
    self.imgView.image = [UIImage imageNamed:@"grzx_account_diamond_icon"];
    
    self.numberLab.text = numberArray[_indexPath.row];
    
}

-(void)setNumberMoneyArray:(NSArray *)numberMoneyArray{
    
    [self.numBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-50);
        make.height.with.mas_equalTo(20);
        make.top.equalTo(self.mas_centerY).offset(-10);
        make.width.mas_equalTo(100*SCREEN_WIDTH_RATIO47);
    }];
    [self.numBtn.layer setCornerRadius:10.0];
    [self.numBtn setTitle:[NSString stringWithFormat:@"%@魅力值",numberMoneyArray[_indexPath.row]] forState:UIControlStateNormal];
    self.numBtn.tag = _indexPath.row;
    [self.numBtn addTarget:self action:@selector(UserExchangenumBtnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

-(void)UserExchangenumBtnClickAction:(UIButton *)sender{

    if ([self.delegate respondsToSelector:@selector(UserExchangenumBtnClickAction:)]) {
        [self.delegate UserExchangenumBtnClickAction:sender];
    }
    
}



@end
